package com.ccs.testcase;

import org.junit.BeforeClass;
import org.junit.FixMethodOrder;
import org.junit.Test;
import org.junit.runners.MethodSorters;
import org.openqa.selenium.WebDriver;

import com.ccs.transmittal.*;
import com.ccs.functions.*;

@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class Transmittal_Details {

	public static String appCode;
	private static WebDriver driver;
	public static String transmittal_number;
	public static double transmittal_amount;
		
	static
	Login in = new Login();
	Misc_Transmittal m = new Misc_Transmittal();
	Admin_Transmittal_List atl = new Admin_Transmittal_List();
	Admin_Create_Transmittal_List actl = new Admin_Create_Transmittal_List();
	
	@BeforeClass
	public static void startBrowser()throws Exception{
		Webdriver d = new Webdriver();
		driver = d.startUp();
	}
	@Test
	public void a_login_app() throws Exception{
		System.out.println("Start Test: Login Admin Console");
		m.maximize_window(driver);
		in.admin(driver);
		System.out.println("End Test: Login Admin Console\n");
	}
	@Test
	public void b_display_transmittal_list_admin() throws Exception{
		System.out.println("Start Test: Goto Transmittal List");
		m.go_to_transmittal_admin(driver);
		System.out.println("End Test: Goto Transmittal List\n");
	}
	@Test
	public void c_test_datepicker() throws Exception{
		System.out.println("Start Test: Date Picker");
		atl.verify_table_header_transmittal_list(driver);
		atl.search_transmittal_list(driver, "cocotrn602", "final", "COCOLIFE HEALTH CARE");
		System.out.println("End Test: Date Picker\n");
	}
	@Test
	public void d_final_transmittal_search_param() throws Exception{
		System.out.println("Start Test: Search Parameter of Final Transmittal");
		atl.search_param_transmittal_list(driver);
		System.out.println("End Test: Search Parameter of Final Transmittal\n");
	}
	@Test
	public void e_check_transmittal_amount_details() throws Exception{
		System.out.println("Start Test: Search Parameter of Final Transmittal");
		atl.check_transmittal_amount_details(driver);
		System.out.println("End Test: Search Parameter of Final Transmittal\n");
	}
	@Test
	public void f_preview_transmittal_memo() throws Exception{
		System.out.println("Start Test: Preview Transmittal Memo");
		atl.preview_transmittal_memo(driver);
		System.out.println("End Test: Preview Transmittal Memo\n");
	}
	@Test
	public void g_goto_create_transmittal_page() throws Exception{
		System.out.println("Start Test: Go to Home Page of Admin Console");
		m.go_to_admin_home(driver);
		m.go_to_transmittal_admin(driver);
		m.go_to_create_transmittal(driver);
		System.out.println("End Test: Go to Home Page of Admin Console\n");
	}
	@Test
	public void h_search_transmittal_manual() throws Exception{
		System.out.println("Start Test: Search for SOA/CI Discharged Yesterday");
		transmittal_number = actl.search_and_generate_soa_ci(driver, "EASTWEST HEALTHCARE", "6/19/2014");
		System.out.println("End Test: Search for SOA/CI Discharged Yesterday\n");
	}
	@Test
	public void i_verify_transmittal_table_headers() throws Exception{
		System.out.println("Start Test: Verify Transmittal Table Headers");
		actl.verify_transmittal_table_headers(driver, true);
		System.out.println("End Test: Verify Transmittal Table Headers\n");
	}
	@Test
	public void j_verify_transmittal_table_details() throws Exception{
		System.out.println("Start Test: Verify Transmittal Table Details");
		actl.verify_search_and_generate_soa_ci_table(driver, "draft", "eastwest");
		actl.verify_transmittal_table_count(driver, "eastwest");
		System.out.println("End Test: Verify Transmittal Table Details\n");
	}
	@Test
	public void k_proceed_to_draft_transmittal() throws Exception{
		System.out.println("Start Test: Proceed with Transmittal");
		actl.proceed_with_transmittal(driver, "eastwest", transmittal_number);
		System.out.println("End Test: Proceed with Transmittal\n");
	}
	@Test
	public void l_verify_transmittal_table_details() throws Exception{
		System.out.println("Start Test: Verify Transmittal Table Details");
		m.verify_table_header_inpatient_hospital(driver);
		m.verify_table_header_outpatient_hospital(driver);
		m.verify_location_edit_transmittal(driver);
		m.verify_hmo_transmittal(driver,"eastwest", transmittal_number);
		m.verify_table_inpatient_alphabetical(driver);
		m.verify_table_outpatient_alphabetical(driver);
		actl.verify_search_and_generate_soa_ci_table(driver,"draft", "eastwest");
		actl.verify_transmittal_table_count(driver, "eastwest");
		System.out.println("End Test: Verify Transmittal Table Details\n");
	}
	@Test
	public void m_compute_transmittal_details() throws Exception{
		System.out.println("Start Test: Compute Transmittal Amount");
		transmittal_amount = actl.compute_transmittal_table_headers(driver);
		System.out.println("End Test: Compute Transmittal Amount\n");
	}
	@Test
	public void n_generate_transmittal() throws Exception{
		System.out.println("Start Test: Generate Transmittal");
		actl.click_generate_transmittal(driver, "23 patient", transmittal_number);
		System.out.println("End Test: Generate Transmittal\n");
	}
	@Test
	public void o_search_final_transmittal() throws Exception{
		System.out.println("Start Test: Search Final Transmittal");
		m.go_to_admin_home(driver);
		m.go_to_transmittal_admin(driver);
		m.check_transmittal_details(driver, transmittal_number, "EASTWEST HEALTHCARE", transmittal_amount, false);
		atl.search_transmittal_list(driver, transmittal_number, "final", "EASTWEST HEALTHCARE");
		System.out.println("End Test: Search Final Transmittal\n");
	}
	@Test
	public void p_verify_transmittal_table_details() throws Exception{
		System.out.println("Start Test: Verify Transmittal Table Details");
		m.verify_location_edit_transmittal(driver);
		m.verify_hmo_final_transmittal(driver);
		m.verify_final_transmittal_date(driver);
		actl.verify_search_and_generate_soa_ci_table(driver, "final", "eastwest");
		actl.verify_transmittal_table_count(driver, "eastwest");
		System.out.println("End Test: Verify Transmittal Table Details\n");
	}
	@Test
	public void q_preview_transmittal_memo() throws Exception{
		System.out.println("Start Test: Preview Transmittal Memo");
		atl.preview_transmittal_memo(driver);
		System.out.println("End Test: Preview Transmittal Memo\n");
	}
	@Test
	public void r_logout_app() throws Exception{
		System.out.println("Start Test: Logout Admin Console");
		Logout out = new Logout();
		out.admin(driver);
		System.out.println("End Test: Logout Admin Console\n");
	}
}
